var id = getUrlQueryString('index');
$("#cno").attr("value",id);
function getUrlQueryString(names, urls) {
    urls = urls || window.location.href;
    urls && urls.indexOf("?") > -1 ? urls = urls
        .substring(urls.indexOf("?") + 1) : "";
    var reg = new RegExp("(^|&)" + names + "=([^&]*)(&|$)", "i");
    var r = urls ? urls.match(reg) : window.location.search.substr(1)
        .match(reg);
    if (r != null && r[2] != "")
        return unescape(r[2]);
    return null;
};
$("#btn").click(function () {
    var cname = $("#cname").val();
    var cno = $("#cno").val();
    var credit = $("#credit").val();
    var capacity = $("#capacity").val();
    var address = $("#address").val();
    $.ajax({
        url:"/RuanJianKeShe/updateCourseInfo",
        type:"post",
        data:{
            "msg":"updateCourseInfo",
            "cname":cname,
            "cno":cno,
            "credit":credit,
            "capacity": capacity,
            "address":address
        },
        dataType:"json",
        success:function(success){
            alert(success)
        },
        error:function(){
            alert("fail");
        }
    })
    window.history.back();
})

